﻿///////////////////////////////////////////////////////////////////////
// Name: ConfigTerminal.cs
// Author: B. Gian James <gian@BattleDroids.net>
// Description:  The terminal configuration form
//
// $Id: ConfigTerminal.cs,v 1.1.1.1 2009/08/23 11:09:37 gian Exp $
///////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;

namespace AVR_Terminal
{
    public partial class ConfigTerminal : Form
    {
        StopBits[] sb = { StopBits.None, StopBits.One, StopBits.Two };
        Parity[] pa = { Parity.None, Parity.Odd, Parity.Even, Parity.Mark, Parity.Space };

        Color fontColor = Properties.Settings.Default.UserFontColor;
        Color backgroundColor = Properties.Settings.Default.UserBackgroundColor;

        public ConfigTerminal()
        {
            InitializeComponent();
            InitData();
        }
        private void InitData()
        {

            comboStopBit.DataSource = sb;

            //comboStopBit.DisplayMember
            comboFlowControl.DataSource = Program.flowControls;
            comboFlowControl.DisplayMember = "Name";
            comboFlowControl.ValueMember = "FlowControl";

            comboParity.DataSource = pa;

            comboFlowControl.SelectedItem = Properties.Settings.Default.SerialFlow;
            comboParity.SelectedItem = Properties.Settings.Default.SerialParity;
            comboStopBit.SelectedItem = Properties.Settings.Default.SerialStopBits;
            numDataBit.Value = Properties.Settings.Default.SerialDataBits;

            labelFont.Font = new Font(MainForm.pfc.Families[0], 9);
        }

        private void buttonResetFont_Click(object sender, EventArgs e)
        {
            labelFont.Font = new Font(MainForm.pfc.Families[0], 9);
        }

        private void buttonNewFont_Click(object sender, EventArgs e)
        {
            fontDialog1 = new FontDialog();
            if (fontDialog1.ShowDialog() == DialogResult.OK)
            {
                labelFont.Font = fontDialog1.Font;
            }
        }

        private void buttonFontColor_Click(object sender, EventArgs e)
        {
            colorDialog1 = new ColorDialog();
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                Properties.Settings.Default.UserFontColor = colorDialog1.Color;
            }
        }

        private void buttonBackgroundColor_Click(object sender, EventArgs e)
        {
            colorDialog1 = new ColorDialog();
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                Properties.Settings.Default.UserBackgroundColor = colorDialog1.Color;
            }
        }
    }

}
